<?php


namespace app\service;

use app\elastic\OrderElastic;

class OrderService extends BaseService
{
    protected $orderElastic;

    public function __construct()
    {
        $this->orderElastic = new OrderElastic();
    }

    public function searchOrderList($userId=0,$param=[])
    {

        $where['buyer_id'] = $userId;
        if($param['status']){
            $where['order_status'] = $param['status'];
        }

        $order = $this->orderElastic->filter($where)
                ->paginate($param['page'],$param['size'])
                ->search();

        $res = [
            'total' => $order['total'],
            'orderList' => $order['data']
        ];
        return $res;
    }

}